/**
 * Created by kangdaye on 16/6/5.
 */
app.controller('employeeAEDialogCtr',["$scope","$rootScope","addEditModel","gridOpt","employeeService", function($scope,$rootScope,addEditModel,gridOpt,employeeService) {
    $scope.getData = {
        name : '',
        phone : '',
        weixin : '',
        scope : ''
    };

    if(addEditModel != 'add'){
        $scope.getData = angular.copy(addEditModel);
    }

    $scope.submit = function(){
        if(addEditModel === 'add'){
            employeeService.add($scope.getData,function(){
                gridOpt.refresh();
                $scope.closeThisDialog();  //dialog 关闭
            });
            return;
        }

        employeeService.update($scope.getData,function(){
            angular.extend(addEditModel,$scope.getData);
            $scope.closeThisDialog();  //dialog 关闭
        });
    }

}]);
